<layout name="layout"/>
<include file="./nav"/>

	<!-- BEGIN PAGE LEVEL STYLES -->

	<link rel="stylesheet" href="__PUBLIC__/media/css/DT_bootstrap.css" />

	<!-- END PAGE LEVEL STYLES -->

<!-- BEGIN CONTAINER -->

<div class="page-container row-fluid">

	<!-- BEGIN PAGE -->

	<div class="page-content">


		<!-- BEGIN PAGE CONTAINER-->

		<div class="container-fluid">

			<!-- BEGIN PAGE HEADER-->

			<div class="row-fluid">

				<div class="span12">

					<!-- BEGIN PAGE TITLE & BREADCRUMB-->

					<h3 class="page-title">{$_page_title}</h3>

					<ul class="breadcrumb">

						<li>

							<i class="icon-home"></i>

							<a href="index.html">首页</a>

							<i class="icon-angle-right"></i>

						</li>

						<li>

							<a href="#">{$_module_name}</a>

							<i class="icon-angle-right"></i>

						</li>

						<li><a href="#">{$_page_btn_name}</a></li>

					</ul>

					<!-- END PAGE TITLE & BREADCRUMB-->

				</div>

			</div>

			<!-- END PAGE HEADER-->

			<!-- BEGIN PAGE CONTENT-->

			<div class="row-fluid">

				<div class="span12">

					<!-- BEGIN SAMPLE TABLE PORTLET-->

					<div class="portlet box blue">

						<div class="portlet-title">

							<div class="caption"><i ></i>商品库存</div>

							<div class="tools">

								<a href="javascript:;" class="collapse"></a>

								<a href="#portlet-config" data-toggle="modal" class="config"></a>

								<a href="javascript:;" class="reload"></a>

								<a href="javascript:;" class="remove"></a>

							</div>

						</div>

						<div class="portlet-body no-more-tables">
							<form method="post" action="__SELF__">
							<table class="table-bordered table-striped table-condensed cf">

								<thead class="cf" >

								<tr style="text-align: left">
									<?php foreach($gaData as $k=>$v): ?>
									<th width="120"><?php echo $k; ?></th>
									<?php endforeach; ?>
									<th width="120">库存量</th>
									<th width="60">操作</th>
								</tr>

								</thead>

								<tbody>
								<?php if($gnData): ?>
								<?php foreach($gnData as $key => $val): ?>
								<tr>
									<?php
										$gaCount = count($gaData);
										foreach($gaData as $k => $v): ?>
									<td >
										<select name="goods_attr_id[]">
											<option value="">请选择</option>
											<?php foreach($v as $k1 => $v1):
												$_attr = explode(',',$val['goods_attr_id']);
												if(in_array($v1['id'],$_attr)){
												$select = 'selected="selected"';
												} else {
												$select = '';
												}
											?>
											<option <?php echo $select; ?>value="<?php echo $v1['id']; ?>"><?php echo $v1['attr_value']; ?></option>
											<?php endforeach; ?>
										</select>
									</td>
									<?php endforeach; ?>
									<td ><input type="text" name="goods_number[]" value="<?php echo $val['goods_number']; ?>"/></td>
									<td><input type="button" onclick="addNewTr(this);" value="<?php echo $key == 0 ? '+' : '-'; ?>"/></td>
								</tr>
								<?php endforeach; ?>
								<?php else: ?>
								<tr class="tron">
									<?php
										$gaCount = count($gaData);
										foreach($gaData as $k => $v): ?>
									<td>
										<select name="goods_attr_id[]">
											<option value="">请选择</option>
											<?php foreach($v as $k1 => $v1):?>
											<option value="<?php echo $v1['id']; ?>"><?php echo $v1['attr_value']; ?></option>
											<?php endforeach; ?>
										</select>
									</td>
									<?php endforeach; ?>
									<td><input type="text" name="goods_number[]" /></td>
									<td><input type="button" onclick="addNewTr(this);" value="+"/></td>
								</tr>
								<?php endif; ?>
								<tr id="submit">
									<td align="center" colspan="<?php echo $gaCount+2; ?>"><input type="submit" value="提交"/></td>
								</tr>

								</tbody>

							</table>
								</form>

						</div>

					</div>

					<!-- END SAMPLE TABLE PORTLET-->

				</div>

			</div>

			<!-- END PAGE CONTENT-->

		</div>

		<!-- END PAGE CONTAINER-->

	</div>

	<!-- END PAGE -->

</div>

<!-- END CONTAINER -->

<!-- BEGIN JAVASCRIPTS(Load javascripts at bottom, this will reduce page load time) -->

<!-- BEGIN CORE PLUGINS -->

<script src="__PUBLIC__/media/js/jquery-1.10.1.min.js" type="text/javascript"></script>

<script src="__PUBLIC__/media/js/jquery-migrate-1.2.1.min.js" type="text/javascript"></script>

<!-- IMPORTANT! Load jquery-ui-1.10.1.custom.min.js before bootstrap.min.js to fix bootstrap tooltip conflict with jquery ui tooltip -->

<script src="__PUBLIC__/media/js/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>

<script src="__PUBLIC__/media/js/bootstrap.min.js" type="text/javascript"></script>

<!--[if lt IE 9]>

<script src="__PUBLIC__/media/js/excanvas.min.js"></script>

<script src="__PUBLIC__/media/js/respond.min.js"></script>

<![endif]-->

<script src="__PUBLIC__/media/js/jquery.slimscroll.min.js" type="text/javascript"></script>

<script src="__PUBLIC__/media/js/jquery.blockui.min.js" type="text/javascript"></script>

<script src="__PUBLIC__/media/js/jquery.cookie.min.js" type="text/javascript"></script>

<script src="__PUBLIC__/media/js/jquery.uniform.min.js" type="text/javascript" ></script>

<!-- END CORE PLUGINS -->

<script src="__PUBLIC__/media/js/app.js"></script>

<script>

	jQuery(document).ready(function() {

		// initiate layout and plugins

		App.init();

	});

	function addNewTr(btn) {
		var tr = $(btn).parent().parent();
		if($(btn).val() == "+"){
			var newTr = tr.clone();
			newTr.find(":button").val("-");
			$("#submit").before(newTr);
		} else {
			tr.remove();
		}
	}

</script>
